/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BD;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ARMGARCES
 */
@Entity
@Table(name = "factura_mp")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "FacturaMp.findAll", query = "SELECT f FROM FacturaMp f"),
    @NamedQuery(name = "FacturaMp.findByIdFacturamp", query = "SELECT f FROM FacturaMp f WHERE f.idFacturamp = :idFacturamp"),
    @NamedQuery(name = "FacturaMp.findByNumero", query = "SELECT f FROM FacturaMp f WHERE f.numero = :numero"),
    @NamedQuery(name = "FacturaMp.findByControl", query = "SELECT f FROM FacturaMp f WHERE f.control = :control"),
    @NamedQuery(name = "FacturaMp.findByFecha", query = "SELECT f FROM FacturaMp f WHERE f.fecha = :fecha")})
public class FacturaMp implements Serializable {
    @Basic(optional =     false)
    @Column(name = "fecha")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idFactura_mp")
    private Integer idFacturamp;
    @Basic(optional = false)
    @Column(name = "numero")
    private String numero;
    @Basic(optional = false)
    @Column(name = "control")
    private String control;
    @JoinTable(name = "fact_oc_mp", joinColumns = {
        @JoinColumn(name = "fk_idFactura_mp", referencedColumnName = "idFactura_mp")}, inverseJoinColumns = {
        @JoinColumn(name = "fk_idOrdenCompra_mp", referencedColumnName = "idOrdenCompra_mp")})
    @ManyToMany
    private List<OrdencompraMp> ordencompraMpList;
    @JoinColumn(name = "fk_idProveedor", referencedColumnName = "idProveedor")
    @ManyToOne(optional = false)
    private Proveedor fkidProveedor;
    @OneToMany(mappedBy = "fkidFacturamp")
    private List<InventarioMp> inventarioMpList;

    public FacturaMp() {
    }

    public FacturaMp(Integer idFacturamp) {
        this.idFacturamp = idFacturamp;
    }

    public FacturaMp(Integer idFacturamp, String numero, String control, Date fecha) {
        this.idFacturamp = idFacturamp;
        this.numero = numero;
        this.control = control;
        this.fecha = fecha;
    }

    public Integer getIdFacturamp() {
        return idFacturamp;
    }

    public void setIdFacturamp(Integer idFacturamp) {
        this.idFacturamp = idFacturamp;
    }

    public String getNumero() {
        return numero;
    }

    public void setNumero(String numero) {
        this.numero = numero;
    }

    public String getControl() {
        return control;
    }

    public void setControl(String control) {
        this.control = control;
    }

    @XmlTransient
    public List<OrdencompraMp> getOrdencompraMpList() {
        return ordencompraMpList;
    }

    public void setOrdencompraMpList(List<OrdencompraMp> ordencompraMpList) {
        this.ordencompraMpList = ordencompraMpList;
    }

    public Proveedor getFkidProveedor() {
        return fkidProveedor;
    }

    public void setFkidProveedor(Proveedor fkidProveedor) {
        this.fkidProveedor = fkidProveedor;
    }

    @XmlTransient
    public List<InventarioMp> getInventarioMpList() {
        return inventarioMpList;
    }

    public void setInventarioMpList(List<InventarioMp> inventarioMpList) {
        this.inventarioMpList = inventarioMpList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idFacturamp != null ? idFacturamp.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FacturaMp)) {
            return false;
        }
        FacturaMp other = (FacturaMp) object;
        if ((this.idFacturamp == null && other.idFacturamp != null) || (this.idFacturamp != null && !this.idFacturamp.equals(other.idFacturamp))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "BD.FacturaMp[ idFacturamp=" + idFacturamp + " ]";
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }
    
}
